﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace ImaginationFactory.Dialogs
{
    /// <summary>
    /// RotateDialog.xaml 的交互逻辑
    /// </summary>
    public partial class RotateDialog : Window
    {
        MainWindow mWindowTemp;
        static MainListBox mListBox;
        int rotateAngleTemp;

        public RotateDialog( MainWindow mWindow )
        {
            InitializeComponent();
            mWindowTemp = mWindow;
        }

        private void txtAngle_TextChanged(object sender, TextChangedEventArgs e)
        {
            //判断数据合理性
            if (Convert.ToInt32(txtAngle.Text) >= 0)
            {
                rotateAngleTemp = Convert.ToInt32(txtAngle.Text);

            }
            else
            {
                System.Windows.Forms.MessageBox.Show("请输入数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

            } 
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            mWindowTemp.ImageLibrary.RotateImage(rotateAngleTemp);
            mWindowTemp.image.Source = mWindowTemp.ImageLibrary.LoadedImage.Source;
            //mListBox.rotateItem.IsSelected = false;
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //mListBox.rotateItem.IsSelected = false;
            this.Close();
        }

        private void ImageSizeDlg_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }
    }
}
